import java.util.Arrays;

class Student implements Comparable <Student> {
    public String name;
    public int age;
    public int score;
    public Student(String name,int age,int score) {
        this.name=name;
        this.age=age;
        this.score=score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        /*if(this.name.compareTo(o.name)>0){
            return 1;
        }else if(this.name.compareTo(o.name)<0){
            return -1;
        }else{
            return 0;
        }*/
        if(this.age>o.age) {
            return 1;
        }else if(this.age<o.age) {
            return -1;
        }else {
            return 0;
        }
    }
}

public class demo {
    public static void main(String[] args) {
        Student[] students=new Student[3];
        students[0]=new Student("zhangsan",18,20);
        students[1]=new Student("lisi",30,60);
        students[2]=new Student("wangwu",20,90);
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
    }
}